package handler

import (
	"course-hub/user-srv/basic/handler/config"
	"course-hub/user-srv/basic/handler/model"
	"github.com/gin-gonic/gin"
	"net/http"
)

func ListUser(c *gin.Context) {

	var User model.User
	err := c.ShouldBind(&User)
	if err != nil {
		c.JSON(http.StatusBadRequest, gin.H{
			"code": 0,
			"msg":  "解析失败",
		})
		return
	}
	err = config.DB.Find(&User).Error
	if err != nil {
		c.JSON(http.StatusBadRequest, gin.H{
			"code": 0,
			"msg":  "查询失败",
		})
		return
	}
	c.JSON(http.StatusOK, gin.H{
		"code": 500,
		"msg":  "查询成功",
		"data": User,
	})
}
